using System;
using System.Collections.Generic;

using DJY.Code;
using DJY.Domain.ViewModel;
using DJY.Domain.ViewModel.WorkFlow;

namespace DJY.Service.WorkFlow
{
    public interface IWorkFlowEngine:IDependency
    {

        #region 流程分类
        /// <summary>
        /// 获取模块按钮权限
        /// </summary>
        /// <param name="userId">登陆用户</param>
        /// <returns></returns>
        List<string> GetCateModuleButtons(string userId);

        /// <summary>
        /// 保存流程分类
        /// </summary>
        /// <param name="categroy">分类信息</param>
        /// <returns>操作结果</returns>
        EditItemResult SaveCategory(WorkFlowCategory categroy);

        /// <summary>
        /// 设置流程分类状态
        /// </summary>
        /// <param name="ids">键列表</param>
        /// <param name="state">状态</param>
        /// <param name="userId">操作用户ID</param>
        /// <returns>操作结果</returns>
        EditItemResult DeleteCategory(List<string> ids,bool state,string userId);

        /// <summary>
        /// 彻底删除分类
        /// </summary>
        /// <param name="ids">键列表</param>
        /// <param name="userId">操作用户ID</param>
        /// <returns>操作结果</returns>
        EditItemResult RemoveCategory(List<string> ids,string userId);

        /// <summary>
        /// 流程分类查询
        /// </summary>
        /// <param name="queryInfo">分类查询信息</param>
        /// <returns>查询结果</returns>
        PagedResult QueryCategory(WFCategoryQueryInfo queryInfo);

        /// <summary>
        /// 查询流程分类
        /// </summary>
        /// <param name="queryInfo">查询信息</param>
        /// <returns>查询结果</returns>
        List<WorkFlowCategory> CategoryList(WFCategoryQueryInfo queryInfo);
        #endregion

        #region 流程消息
        /// <summary>
        /// 我的待处理信息列表
        /// </summary>
        /// <param name="userId">操作人</param>
        /// <param name="state">状态</param>
        /// <param name="top">获取数据量</param>
        /// <returns></returns>
        List<WfMyMsg> MyMsgList(string userId, int state = 0, int top = 15);

        /// <summary>
        /// 我的消息查询
        /// </summary>
        /// <param name="queryInfo">查询条件</param>
        /// <returns></returns>
        PagedResult MyMsg(WFMessageQueryInfo queryInfo);

        /// <summary>
        /// 处理个人消息
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <param name="userId">当前处理人ID</param>
        /// <returns></returns>
        ProcessMsgResult ProcessMsg(string id,string userId);

        /// <summary>
        /// 催办
        /// </summary>
        /// <param name="id">消息ID</param>
        /// <param name="userId">当前处理人ID</param>
        /// <returns></returns>
        EditItemResult AddWeight(string id, string userId);
        #endregion

        #region 流程定义
        /// <summary>
        /// 获取模块按钮权限
        /// </summary>
        /// <param name="userId">登陆用户</param>
        /// <returns></returns>
        List<string> GetDefModuleButtons(string userId);

        /// <summary>
        /// 流程定义属性列表
        /// </summary>
        /// <param name="orgId">单位ID</param>
        List<WFDefTreeModel> WfDefTreeList(string orgId);

        /// <summary>
        /// 我的流程列表
        /// </summary>
        /// <param name="userId">用户ID</param>
        List<MyFlowModel> MyFlowList(string userId);

        /// <summary>
        /// 发布流程
        /// </summary>
        /// <param name="ids">流程id</param>
        /// <param name="userId">操作用户</param>
        /// <returns></returns>
        EditItemResult Publish(List<string> ids, string userId);

        /// <summary>
        /// 保存流程
        /// </summary>
        /// <param name="def">流程定义</param>
        EditItemResult Save(WorkFlowDef def);

        /// <summary>
        /// 设置流程状态
        /// </summary>
        /// <param name="ids">键列表</param>
        /// <param name="state">状态</param>
        /// <param name="userId">操作用户ID</param>
        /// <returns>操作结果</returns>
        EditItemResult DeleteFlow(List<string> ids, bool state, string userId);

        /// <summary>
        /// 彻底删除流程
        /// </summary>
        /// <param name="ids">键列表</param>
        /// <param name="userId">操作用户ID</param>
        /// <returns>操作结果</returns>
        EditItemResult RemoveFlow(List<string> ids, string userId);

        /// <summary>
        /// 流程定义查询
        /// </summary>
        /// <param name="queryInfo">流程查询信息</param>
        /// <returns>查询结果</returns>
        List<WorkFlowDef> QueryFlow(WFDefQueryInfo queryInfo);

        /// <summary>
        /// 发起流程
        /// </summary>
        /// <param name="id">流程定义</param>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        EditItemResult StartFlow(string id, string userId);
        #endregion

        #region 流程实例
        /// <summary>
        /// 流程实例查询
        /// </summary>
        /// <param name="queryInfo">流程实例查询</param>
        /// <returns>查询结果</returns>
        PagedResult QueryFlow(WFInstanceQueryInfo queryInfo);

        /// <summary>
        /// 流程实例流转
        /// </summary>
        /// <param name="id">流程实例ID</param>
        /// <returns>查询结果</returns>
        List<WorkFlowInstanceNode> FlowNodeList(string id);

        /// <summary>
        /// 处理流程
        /// </summary>
        /// <param name="model">流程处理对象</param>
        /// <returns></returns>
        ProcessFlowResult Process(ProcessFlowModel model);

        /// <summary>
        /// 终止流程
        /// </summary>
        /// <param name="flowId">流程id</param>
        /// <param name="userId">操作用户</param>
        EditItemResult StopFlow(string flowId, string userId);

        /// <summary>
        /// 获取流程实例
        /// </summary>
        /// <param name="flowId">流程ID</param>
        /// <param name="nodeId">当前处理节点</param>
        /// <param name="userId">当前操作用户</param>
        /// <returns></returns>
        WorkFlowInstance GetWorkFlow(string flowId, string nodeId, string userId);
        #endregion

        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userId">当前登陆用户</param>
        /// <param name="kws">查询关键字</param>
        /// <param name="type">查询类型</param>
        /// <returns></returns>
        Dictionary<string, string> SearchUser(string userId, string kws, string type);

        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="queryInfo">查询条件</param>
        /// <returns></returns>
        List<FlowUserModel> SearchFlowUser(FlowWFMessageQueryInfo queryInfo);
    }
}